#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int minCost(vector<int>& cost) {
	int n = cost.size();
	int dp[1000] = { 0 };
	dp[0] = 0;
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i] = min(dp[i - 1]+cost[i-1], dp[i - 2]+cost[i-2]);
	}
	int mincost = dp[n];
	return mincost;
}

int main()
{
	int n;
	vector<int>cost;
	while (cin >> n) {
		cost.push_back(n);
		if (cin.get() == '\n') break;
	}
	cout << minCost(cost);
	return 0;
}